package com.study.project.config.redis;

import org.springframework.context.annotation.Bean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.scripting.support.ResourceScriptSource;
import org.springframework.stereotype.Service;

/**
 * @program: studyProject
 * @see:
 * @author: yangjie
 * @create: 2024-04-13 17:28
 **/
@Service
public class RedisLuaScript {

    @Bean("counterRedisScript")
    public DefaultRedisScript<Long> counterRedisScript() {
        DefaultRedisScript<Long> defaultRedisScript = new DefaultRedisScript<>();
        defaultRedisScript.setResultType(Long.class);
        defaultRedisScript.setScriptSource(new ResourceScriptSource(new ClassPathResource("lua/Counter.lua")));
        return defaultRedisScript;
    }
}